<?php

  //to do: improve the way to pass two or more parameters in the paged-table ( link )
    
  $aux = explode ( '|', $_GET['id'] );
  $index=0;
  $LocationUid = str_replace ( '"', '', $aux[$index++] );

  require_once ( PATH_PLUGINS . 'hr' . PATH_SEP . 'class.hr.php');
  $pluginObj = new hrClass ();

  require_once ( "classes/model/HrLocations.php" );
  //if exists the row in the database propel will update it, otherwise will insert.
  $tr = HrLocationsPeer::retrieveByPK( $LocationUid  );
  
  if ( ( is_object ( $tr ) &&  get_class ($tr) == 'HrLocations' ) ) { 
     $fields['LOCATION_UID'] = $tr->getLocationUid();
     $fields['LABEL_LOCATION_UID'] = $tr->getLocationUid();
     $fields['DISTRICT_ID'] = $tr->getDistrictId();
     $fields['LABEL_DISTRICT_ID'] = $tr->getDistrictId();
     $fields['LOCATIONSTATE_ID'] = $tr->getLocationstateId();
     $fields['LABEL_LOCATIONSTATE_ID'] = $tr->getLocationstateId();
     $fields['LOCATIONNAME'] = $tr->getLocationname();
     $fields['LABEL_LOCATIONNAME'] = $tr->getLocationname();
     $fields['LOCATIONADDRESS1'] = $tr->getLocationaddress1();
     $fields['LABEL_LOCATIONADDRESS1'] = $tr->getLocationaddress1();
     $fields['LOCATIONADDRESS2'] = $tr->getLocationaddress2();
     $fields['LABEL_LOCATIONADDRESS2'] = $tr->getLocationaddress2();
     $fields['LOCATIONSITE'] = $tr->getLocationsite();
     $fields['LABEL_LOCATIONSITE'] = $tr->getLocationsite();
     $fields['LOCATIONZIPCODE'] = $tr->getLocationzipcode();
     $fields['LABEL_LOCATIONZIPCODE'] = $tr->getLocationzipcode();
     $fields['LOCATIONPHONE'] = $tr->getLocationphone();
     $fields['LABEL_LOCATIONPHONE'] = $tr->getLocationphone();
     $fields['LOCATIONFAX'] = $tr->getLocationfax();
     $fields['LABEL_LOCATIONFAX'] = $tr->getLocationfax();
     $fields['LOCATIONCODE'] = $tr->getLocationcode();
     $fields['LABEL_LOCATIONCODE'] = $tr->getLocationcode();
     $fields['LOCATIONCOMMENTS'] = $tr->getLocationcomments();
     $fields['LABEL_LOCATIONCOMMENTS'] = $tr->getLocationcomments();
     $fields['IRN'] = $tr->getIrn();
     $fields['LABEL_IRN'] = $tr->getIrn();
     $fields['MAINDISTRICTLOCATION'] = $tr->getMaindistrictlocation();
     $fields['LABEL_MAINDISTRICTLOCATION'] = $tr->getMaindistrictlocation();
  }
  else
    $fields = array();  
  
  $G_MAIN_MENU = 'processmaker';
  $G_SUB_MENU = 'hr/menuhrDistricts';
  $G_ID_MENU_SELECTED = 'ID_HR_DIS';
  $G_ID_SUB_MENU_SELECTED = 'ID_HR_LOCATIONS';


  $G_PUBLISH = new Publisher;
  $G_PUBLISH->AddContent('xmlform', 'xmlform', 'hr/hrLocationsDelete', '', $fields, 'hrLocationsDeleteExec' );
  G::RenderPage('publish', 'blank');   
?>